<!-- 库存盘点 -->
<template>
  <div class="app-container">
  <sn-card-with-title>

    <!-- 库存盘点记录 -->
    <stock-check-record-title
      class="margin-bottom"
      slot="title"/>
    <div slot="content">
      <!-- 库存盘点记录 -->
      <stock-check-record-find-bar
        @queryByDate="queryByDate"
        @inputDscValue="getInputDscValue"
        input-placeholder="输入盘点单号"/>
      <stock-check-record-table
        :table-data="stockCheckRecordTableData"/>
    </div>
  </sn-card-with-title>
  </div>
</template>

<script>
import StockCheckRecordTitle from "./children/StockCheckRecordTitle";
import StockCheckRecordTable from "./children/StockCheckRecordTable";
import StockCheckRecordFindBar from "./children/StockCheckRecordFindBar";

//导入查询盘点的方法
import {
  getArrangeAll,
  getArrangeByLike,
  queryStockCheckRecordByDate
} from "@/api/drug_manage/drugManage"


export default {
  name: "Stocktaking",
  data() {
    return {
      stockCheckRecordTableData: [],
    }
  },
  components: {
    StockCheckRecordFindBar,
    StockCheckRecordTitle,
    StockCheckRecordTable,
  },
  methods: {
    //根据时间查询盘点记录
    queryByDate(date) {
      if (date !== null) {
        queryStockCheckRecordByDate(date[0], date[1]).then(res => {

          this.stockCheckRecordTableData = res.data
          // for (let i = 0; i < res.data.length; i++) {
          //   this.$set(this.stockCheckRecordTableData[i], 'ids', i + 1)
          // }
        })
      } else {
        this.toGetArrangeAll()
      }
    },

    toGetArrangeAll() {
      getArrangeAll().then(res => {
        console.log(res);
        // this.$store.state.user
        this.stockCheckRecordTableData = res.data;
        console.log("stockCheckRecordTableData:",this.stockCheckRecordTableData)
        // for (let i = 0; i < res.data.length; i++) {
        //   this.$set(this.stockCheckRecordTableData[i], 'ids', i + 1)
        // }
      })
    },
    getInputDscValue(value) {
      getArrangeByLike(value).then(res => {
        this.stockCheckRecordTableData = res.data;
        // for (let i = 0; i < res.data.length; i++) {
        //   this.$set(this.stockCheckRecordTableData[i], 'ids', i + 1)
        // }
      })
    }
  },
  created() {
    this.toGetArrangeAll()
  }
}
</script>

<style scoped>

</style>
